// pages/view/drug/DoctorsDrugAmount/DoctorsDrugAmount.js
const network = require('../../../../utils/network.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
      drugAmount_list:[
        {
          doctorCode: '101',
          doctorName: '张三',
          clTotal:1000,
          ipTotal: 1000,
          total: 2000
        },
        {
          doctorCode: '102',
          doctorName: '李四',
          clTotal: 1000,
          ipTotal: 1000,
          total: 2000
        },
        {
          doctorCode: '103',
          doctorName: '王五',
          clTotal: 1000,
          ipTotal: 1000,
          total: 2000
        }
      ],
    clDrugFee: 0,
    ipDrugFee: 0,
    totalDrugFee: 0
  },

  /**
    * 生命周期函数--监听页面加载
    */
  onLoad: function (options) {
    var that = this
    wx.showLoading({
      title: '加载中',
    })
    that.myRequest(options)
   
  },
  /**
 * 调用封装好的网络请求，获取数据
 */
  myRequest: function (options) {
    var that = this
    console.log('options:', options)
    //调用封装好的网络请求，获取数据//options.startTime + '&endTime=' + options.endTime
    network.get('/drug/drugamount?startTime=' + options.startTime + '&endTime=' + options.endTime, {})
      .then(function (res) {
        console.log('res:', res)
        var obj1 = res.data.data
        var obj2 = res.data.data_2.clDrugFee
        var obj3 = res.data.data_2.ipDrugFee
        var obj4 = res.data.data_2.totalDrugFee
        that.setData({
          drugAmount_list: obj1,
          clDrugFee: obj2,
          ipDrugFee: obj3,
          totalDrugFee: obj4

        })
        console.log('drugAmount_list:', obj1)

      }).then(function (res) {

        wx.hideLoading()

      }).catch(function (res) {
        console.log(res)
      })
  },


  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})